Except where otherwise noted, this content is Copyright (c) 2020, RTE and licensed under a CC-BY-4.0 license. 
Welcome to this new tutorial. Off course Hadar is well designed to compute study for network adequacy. You can launch Hadar to compute adequacy for the next second or next year.
But Hadar can also be used like a asset investment tool. In this example, thanks to Hadar, we will make the best choice for renewable energy and network investment.

We have a small region, with metropole which doesn't produce anything, a nuclear plan and two small cities with production.
First step parse data with pandas (and plot them)
import numpy as np
import pandas as pd
import hadar as hd
import plotly.graph_objects as go
a = pd.read_csv('a.csv', index_col='date')
fig = go.Figure()
fig.add_traces(go.Scatter(x=a.index, y=a['consumption'], name='load'))
fig.add_traces(go.Scatter(x=a.index, y=a['gas'], name='gas'))
fig.update_layout(title_text='Node A', yaxis_title='MW')
b = pd.read_csv('b.csv', index_col='date')
fig = go.Figure()
fig.add_traces(go.Scatter(x=b.index, y=b['consumption'], name='load'))
fig.update_layout(title_text='Node B (only consumption)', yaxis_title='MW')
c = pd.read_csv('c.csv', index_col='date')
fig = go.Figure()
fig.add_traces(go.Scatter(x=c.index, y=c['nuclear'], name='load'))
fig.update_layout(title_text='Node C (only production)', yaxis_title='MW')
d = pd.read_csv('d.csv', index_col='date')
fig = go.Figure()
fig.add_traces(go.Scatter(x=d.index, y=d['consumption'], name='load'))
fig.add_traces(go.Scatter(x=d.index, y=d['eolien'], name='eolien'))
fig.update_layout(title_text='Node D', yaxis_title='MW')
Next step, code this network with Hadar
line = 2000 # 2000 MW
base = hd.Study(['a', 'b', 'c', 'd'], horizon=8760) \
.add_on_node('a', data=hd.Consumption(name='load', cost=10**6, quantity=a['consumption'])) \
.add_on_node('a', data=hd.Production(name='gas', cost=80, quantity=a['gas'])) \
.add_link(src='a', dest='b', cost=5, quantity=line) \
\
.add_on_node('b', data=hd.Consumption(name='load', cost=10**6, quantity=b['consumption'])) \
.add_link(src='b', dest='c', cost=5, quantity=line) \
\
.add_on_node('c', data=hd.Production(name='nuclear', cost=50, quantity=c['nuclear'])) \
.add_link(src='c', dest='a', cost=5, quantity=line) \
.add_link(src='c', dest='b', cost=10, quantity=line) \
.add_link(src='c', dest='d', cost=10, quantity=line) \
\
.add_on_node('d', data=hd.Consumption(name='load', cost=10**6, quantity=d['consumption'])) \
.add_on_node('d', data=hd.Production(name='eolien', cost=20, quantity=d['eolien'])) \
.add_link(src='d', dest='c', cost=10, quantity=line)
optimizer = hd.LPOptimizer()
def compute_cost(study):
res = optimizer.solve(study)
agg = hd.ResultAnalyzer(study=study, result=res)
return sum([agg.get_cost(n).sum() for n in agg.nodes])
base_cost = compute_cost(base)
base_cost
An investissor want to build a solar park with solar cells. According to last last data meteo, he could except the amount of production from this park. (Solar radiation is the same on each node of network).
What is the best node to install these solar pans ? (B is excluded because there are not enough space)
park = pd.read_csv('solar.csv', index_col='date')
fig = go.Figure()
fig.add_traces(go.Scatter(x=park.index, y=park['solar'], name='solar'))
fig.update_layout(title_text='Forecast Solar Park Power', yaxis_title='MW')
solar = hd.Production(name='solar', cost=10, quantity=park.values.flatten())
from copy import deepcopy
costs = pd.Series(data=[0, 0, 0], name='cost', index=['a', 'c', 'd'])
We use start three studies one for each node.
for node in costs.index:
print('Start', node,' ', end='')
study = deepcopy(base)
study.add_on_node(node, data=solar)
costs[node] = compute_cost(study)
print('OK')
% of cost evolution
(base_cost - costs) / base_cost * 100
As we can see, network is more efficient if solar park is installed one node A (7.8% more efficient than only 2% for other node)
Add an extra difficulties ! Region want to invest in a new line between A->C, D->B, A->D, D->A.
In this case, What is the best place to install solar park and what is the more usefull line to build ?
costs2 = pd.DataFrame(data={'a->c': [0, 0, 0], 'd->b': [0, 0, 0], 'a->d': [0, 0, 0], 'd->a': [0, 0, 0]},
index=['a', 'c', 'd'])
for node in costs2.index:
for border in costs2.columns:
print('Start', node, border, end=' ')
study =deepcopy(base)
study.add_on_node(node, data=solar)
study.add_link(src=border[0], dest=border[-1], cost=10, quantity=line)
costs2[border][node] = compute_cost(study)
print('OK')
% of cost evolution
(base_cost - costs2) / base_cost * 100
Very interesting, new line is a game changer. D->A and D->B seem most valuable lines. If D->B is created, it's more efficient to install solar park on node D !